package com.fowo.api.sys.ssf.def;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Component;

/**
 * 简单状态定义集
 * @author yl_ls
 */
@Component
public class SimpleStatusFlowDefs {

  private final Map<String, SimpleStatusFlowDef> flowDefs = new HashMap<>();

  public SimpleStatusFlowDefs() {
    SimpleStatusFlowDef f = new SimpleStatusFlowDef();
    f.setObjectName("SupplierTask");
    f.setStatusField("status");
    f.setItems(
      List.of(
        new SimpleStatusFlowDef.Item()
          .setId("S0")
          .setOldValue("*")
          .setNewValue("1")
          .setTitle("草稿"),
        new SimpleStatusFlowDef.Item()
          .setId("S1")
          .setOldValue("1")
          .setNewValue("2")
          .setTitle("已提交"),
        new SimpleStatusFlowDef.Item()
          .setId("S2")
          .setOldValue("2")
          .setNewValue("3")
          .setTitle("已拾取"),
        new SimpleStatusFlowDef.Item()
          .setId("S3")
          .setOldValue("*")
          .setNewValue("7")
          .setTitle("已转发"),
        new SimpleStatusFlowDef.Item()
          .setId("S4")
          .setOldValue("3")
          .setNewValue("6")
          .setTitle("已完成")
      )
    );
    flowDefs.put("SupplierTask", f);

    f = new SimpleStatusFlowDef();
    f.setObjectName("PurchaseOrder");
    f.setStatusField("stauts");
    f.setItems(
      List.of(
        new SimpleStatusFlowDef.Item()
          .setId("S0")
          .setNewValue("0")
          .setTitle("创建"),
        new SimpleStatusFlowDef.Item()
          .setId("S1")
          .setOldValue("0")
          .setNewValue("121")
          .setTitle("审核"),
        new SimpleStatusFlowDef.Item()
          .setId("S2")
          .setOldValue("121")
          .setNewValue("1")
          .setTitle("下单"),
        new SimpleStatusFlowDef.Item()
          .setId("S3")
          .setOldValue("1")
          .setNewValue("2")
          .setTitle("待到货"),
        new SimpleStatusFlowDef.Item()
          .setId("S4")
          .setOldValue("2")
          .setNewValue("9")
          .setTitle("已完成")
      )
    );
    flowDefs.put("PurchaseOrder", f);

    f = new SimpleStatusFlowDef();
    f.setObjectName("SupplierPatrolTask");
    f.setStatusField("status");
    f.setItems(
      List.of(
        new SimpleStatusFlowDef.Item()
          .setId("S0")
          .setOldValue("*")
          .setNewValue("1")
          .setTitle("草稿"),
        new SimpleStatusFlowDef.Item()
          .setId("S1")
          .setOldValue("1")
          .setNewValue("2")
          .setTitle("已提交"),
        new SimpleStatusFlowDef.Item()
          .setId("S2")
          .setOldValue("2")
          .setNewValue("3")
          .setTitle("已拾取"),
        new SimpleStatusFlowDef.Item()
          .setId("S3")
          .setOldValue("*")
          .setNewValue("7")
          .setTitle("已转发"),
        new SimpleStatusFlowDef.Item()
          .setId("S4")
          .setOldValue("3")
          .setNewValue("5")
          .setTitle("已完成")
      )
    );
    flowDefs.put("SupplierPatrolTask", f);

    f = new SimpleStatusFlowDef();
    f.setObjectName("SupplierReview");
    f.setStatusField("status");
    f.setItems(
      List.of(
        new SimpleStatusFlowDef.Item()
          .setId("S0")
          .setOldValue("*")
          .setNewValue("1")
          .setTitle("草稿"),
        new SimpleStatusFlowDef.Item()
          .setId("S1")
          .setOldValue("1")
          .setNewValue("2")
          .setTitle("已提交"),
        new SimpleStatusFlowDef.Item()
          .setId("S2")
          .setOldValue("2")
          .setNewValue("5")
          .setTitle("已通过")
      )
    );
    flowDefs.put("SupplierReview", f);

    f = new SimpleStatusFlowDef();
    f.setObjectName("NavSellOrder");
    f.setStatusField("status");
    f.setItems(
      List.of(
        new SimpleStatusFlowDef.Item()
          .setId("S0")
          .setOldValue("*")
          .setNewValue("1")
          .setTitle("待审核"),
        new SimpleStatusFlowDef.Item()
          .setId("S1")
          .setOldValue("1")
          .setNewValue("3")
          .setTitle("待发货"),
        new SimpleStatusFlowDef.Item()
          .setId("S2")
          .setOldValue("3")
          .setNewValue("4")
          .setTitle("发货中")
      )
    );
    flowDefs.put("NavSellOrder", f);

    f = new SimpleStatusFlowDef();
    f.setObjectName("SupplierTempTask");
    f.setStatusField("status");
    f.setItems(
      List.of(
        new SimpleStatusFlowDef.Item()
          .setId("S0")
          .setOldValue("*")
          .setNewValue("1")
          .setTitle("草稿"),
        new SimpleStatusFlowDef.Item()
          .setId("S1")
          .setOldValue("1")
          .setNewValue("2")
          .setTitle("已提交"),
        new SimpleStatusFlowDef.Item()
          .setId("S2")
          .setOldValue("2")
          .setNewValue("3")
          .setTitle("已拾取"),
        new SimpleStatusFlowDef.Item()
          .setId("S3")
          .setOldValue("*")
          .setNewValue("7")
          .setTitle("已转发"),
        new SimpleStatusFlowDef.Item()
          .setId("S4")
          .setOldValue("3")
          .setNewValue("6")
          .setTitle("已完成")
      )
    );
    flowDefs.put("SupplierTempTask", f);

    f = new SimpleStatusFlowDef();
    f.setObjectName("SupplierMyTask");
    f.setStatusField("status");
    f.setItems(
      List.of(
        new SimpleStatusFlowDef.Item()
          .setId("S0")
          .setOldValue("*")
          .setNewValue("1")
          .setTitle("草稿"),
        new SimpleStatusFlowDef.Item()
          .setId("S1")
          .setOldValue("1")
          .setNewValue("2")
          .setTitle("已提交"),
        new SimpleStatusFlowDef.Item()
          .setId("S2")
          .setOldValue("2")
          .setNewValue("6")
          .setTitle("已完成")
      )
    );
    flowDefs.put("SupplierMyTask", f);

    f = new SimpleStatusFlowDef();
    f.setObjectName("NavAfterSellOrder");
    f.setStatusField("status");
    f.setItems(
      List.of(
        new SimpleStatusFlowDef.Item()
          .setId("S0")
          .setNewValue("1")
          .setTitle("待提交"),
        new SimpleStatusFlowDef.Item()
          .setId("S1")
          .setOldValue("1")
          .setNewValue("2")
          .setTitle("待审核"),
        new SimpleStatusFlowDef.Item()
          .setId("S2")
          .setOldValue("2")
          .setNewValue("3")
          .setTitle("处理中"),
        new SimpleStatusFlowDef.Item()
          .setId("S3")
          .setOldValue("3")
          .setNewValue("4")
          .setTitle("已完成")
      )
    );
    flowDefs.put("NavAfterSellOrder", f);

    f = new SimpleStatusFlowDef();
    f.setObjectName("OrderPicking");
    f.setStatusField("status");
    f.setItems(
      List.of(
        new SimpleStatusFlowDef.Item()
          .setId("S0")
          .setOldValue("*")
          .setNewValue("1")
          .setTitle("待审核"),
        new SimpleStatusFlowDef.Item()
          .setId("S1")
          .setOldValue("1")
          .setNewValue("2")
          .setTitle("待发货"),
        new SimpleStatusFlowDef.Item()
          .setId("S2")
          .setOldValue("2")
          .setNewValue("3")
          .setTitle("发货中"),
        new SimpleStatusFlowDef.Item()
          .setId("S3")
          .setOldValue("3")
          .setNewValue("4")
          .setTitle("已发货")
      )
    );
    flowDefs.put("OrderPicking", f);
  }

  public SimpleStatusFlowDef getFlowDef(String objectName) {
    return flowDefs.get(objectName);
  }
}
